package com.tb.controller;

import com.tb.dto.ProductDto;
import com.tb.service.IProductService;
import com.tb.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired(required = false)
    private IProductService productService;

    @PostMapping("/add")
    public AjaxResult add(@RequestBody ProductDto productDto) {
//        try {
//            productService.add(productDto);
//            return new AjaxResult();
//        } catch (RuntimeException e) {
//            e.printStackTrace();
//            return new AjaxResult(false,e.getMessage());
//        } catch (Exception e) {
//            return new AjaxResult(false, "操作失败");
//        }
        return productService.add(productDto);
    }
}
